package org.bbs.demo.reply.dao;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.bbs.demo.reply.dto.ReplyDto;
import org.bbs.demo.reply.dto.StoreyReplyDto;

@Mapper
public interface StoreyReplyDao {
    @Insert("insert into storey_reply(storey_r_id,user_id,r_id,BBS_user_id,s_r_text,s_r_time,s_r_likes)" +
            "values(#{storey_r_id},#{user_id},#{r_id},#{BBS_user_id},#{s_r_text},#{s_r_time},#{s_r_likes})")
    public int addStoreyReply(StoreyReplyDto storeyreplydto);

    @Select("select user_id from bbsusers where user_id = #{user_id}")
    public String findUser(String user_id);

    @Select("select r_id from bbsreply where r_id = #{r_id}")
    public String findReply(String r_id);

    @Update("update bbsreply set r_reply_num = r_reply_num + 1 where r_id = #{r_id}")
    public int updateRReplyNum(String r_id);

    //@Select("select user_id from bbsreply where r_id = #{r_id}")
    //public String findUidFromRid(String r_id);
}
